#encoding:utf8

import os
import win32api
import win32con
from lib import *

def printlog(text):
	try:
		flog(text)
	except UnicodeEncodeError as ex:
		pass


def isFileHidden(fname):
	attribute	= win32api.GetFileAttributes(fname)
	return attribute & win32con.FILE_ATTRIBUTE_HIDDEN

def scanserver(remotename):
	print('------process server:', remotename) 

	for root, dirs, files in os.walk(remotename):
		for name in dirs:
			fname	= os.path.join(root, name)
			if isFileHidden(fname):
				printlog(fname)
				dirs.remove(name)

		for name in files:
			if name == 'Thumbs.db':
				continue
			fname	= os.path.join(root, name)
			if isFileHidden(fname):
				printlog(fname)


if __name__=='__main__':
	servers		= {r'\\10.12.0.10': ['Public'], r'\\10.12.0.110': ['Public'], r'\\10.12.0.111' : ['Public', 'media(zbr)'] }
	for ip, folders in list(servers.items()):
		for folder in folders:
			remotename	= '%s\\%s'%(ip, folder)
			scanserver(remotename)
